using System;
using CustomerContactSystem.Core.Infrastructure.Domain;

namespace CustomerContactSystem.Core.Model {    
    public class EnquiryComment : Entity {
        public virtual Enquiry Enquiry { get; set; }
        public virtual User AddedBy { get; set; }
        public virtual DateTime CommentDate { get; set; }
        public virtual string Comment { get; set; }
        public virtual bool SentToFixYourStreet { get; set; }
        public virtual int FixYourStreetCommentId { get; set; }

        protected override void Validate() {
            if (Enquiry == null) {
                AddBrokenRule(new BusinessRule("Enquiry", "Enquiry is required!"));
            }

            if (AddedBy == null || AddedBy.Id == 0) {
                AddBrokenRule(new BusinessRule("AddedBy", "Added by is required!"));
            }

            if (CommentDate == DateTime.MinValue) {
                AddBrokenRule(new BusinessRule("CommentDate", "Comment date is required!"));
            }

            if (string.IsNullOrEmpty(Comment)) {
                AddBrokenRule(new BusinessRule("Comment", "Comment is required!"));
            }
        }
    }
}